//
//  ProblemNextController.m
//  AntsExpress
//
//  Created by slccper on 16/1/18.
//  Copyright © 2016年 slccper. All rights reserved.
//

#import "ProblemNextController.h"
#import "ProblemController.h"
@interface ProblemNextController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSMutableArray *_tableList;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ProblemNextController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"常見問題";
    self.tableView.rowHeight=50;
    self.tableView.tableFooterView=[[UIView alloc]init];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)getWebData
{
    if ([clsOtherFun CheckNetworkStatus:YES]) {
        [clsOtherFun showLoadingView:@"正在獲取數據..."];
        if (ants) {
            ants.delegate=nil;
            ants=nil;
        }
        ants = [[clsAntsService alloc]init];
        ants.delegate=self;
        [ants GetQuestioTitle:[self.dic objectForKey:@"id"]];
    }
}
#pragma mark - UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _tableList.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"TaobaoCell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        //        cell.parentViewController=self;
    }
    NSDictionary *dic = [_tableList objectAtIndex:indexPath.section];
    [cell.textLabel setText:[dic objectForKey:@"Ctitle"]];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic = [_tableList objectAtIndex:indexPath.section];
    ProblemController *next = [[ProblemController alloc]initWithNibName:@"ProblemController" bundle:nil];
    next.dic=dic;
    next.isBack=YES;
    [self.navigationController pushViewController:next animated:YES];
}
-(void)getAntsDataSuccess:(NSInteger)type :(NSMutableDictionary *)pDictionary
{
    [clsOtherFun hideLoadingView];
    NSDictionary *dic = [pDictionary objectForKey:@"data"];
    NSString *status = [dic objectForKey:@"status"];
    if ([status integerValue]==200) {
        if ([[dic objectForKey:@"data"]isKindOfClass:[NSArray class]]) {
            _tableList = [dic objectForKey:@"data"];
            [self.tableView reloadData];
        }
        
    }else{
        [clsOtherFun ShowMsgWithNoData];
    }
    
}
@end
